<?php

//欢迎界面
Route::get('/admin', function () {
//    return view('auth.login');
    return redirect('/system');

});

//用户登录
Route::group(array('prefix' => 'admin'), function(){

    Route::auth();
});

//后台
Route::group(['middleware' => 'auth'], function () {

    //system管理
    require 'Routes/Admin/system.php';

    //shop管理
    require 'Routes/Admin/shop.php';

    //ad管理
    require 'Routes/Admin/ads.php';

    //lesson vue
    require 'Routes/Admin/lesson.php';

});

//前端

//wechat接口
Route::group(['namespace'=>'Home\Wechat'],function(){
    Route::any('/api','ApiController@server');
});

//Wechat 管理
Route::group(array('namespace'=>'Home\Wechat','middleware'=>['oauth']), function(){


    Route::get('/','IndexController@index'); //显示微信商城首页

    Route::group(['prefix' => 'wechat'],function(){
        //显示商品列表(从获取到的category_id中，找出对应category_id的所有商品)
        Route::get('/product/index','ProductController@index');
        Route::get('/product/category','ProductController@category'); //显示商品栏目分类首页
        Route::get('/product/search','ProductController@search');//首页 搜索商品
        Route::get('/product/{id}','ProductController@show'); //显示product商品详情

        //购物车
        Route::group(['prefix'=>'carts'],function(){
            //显示购物车首页
            Route::get('/index','CartController@index');

            //ajax实现购物车商品数量增减
            Route::patch('/change_num','CartController@change_num');

            //ajax实现删除购物车商品
            Route::delete('/delete_cart','CartController@delete_cart');

            //ajax实现商品存储到购物车
            Route::post('/store','CartController@store');
        });


        //订单
        Route::get('/order/checkout','OrderController@checkout');  //下单
        Route::get('/order/index','OrderController@index'); //查看订单
        Route::post('/order/store','OrderController@store');  //生成订单
        Route::get('/order/show_pay/{id}','OrderController@show_pay'); //生成订单成功后 跳转到微信支付页面

        //我的订单
        Route::get('/order/show/{id}','OrderController@show');
        //删除订单
        Route::delete('/order/destroy/{id}','OrderController@destroy');


        //地址管理
//    Route::get('/address/index','AddressController@index'); //显示地址列表
//    Route::get('/address/create','AddressController@create'); //显示创建地址
        Route::get('/address/manage','AddressController@manage'); //管理地址
        Route::patch('/address/default_address','AddressController@default_address');//设置默认收货地址
        Route::resource('address','AddressController'); //地址 资源类型



        //服务
        Route::get('/customer/index','CustomerController@index');
    });


});






